<template>
<el-dialog
        :close-on-click-modal="false"
        class="rl-dialog-header"
        :visible.sync="formVisible"
        :title="this.stype"
        @open="formInit"
        style="width: 90%; margin: 0 auto"
        :before-close="dialogClose"
        width="80%"
    >
    <div style="width: 100%; height: auto">
        <!-- 基本信息 -->
        <div style="border: 0px solid #f00; margin-top: 0.5%; border-radius: 25px; background-color: #fff">
            <div style="width: 98%; margin-left: 1%">
                <el-divider></el-divider>
                <br />
                <el-form :model="form" status-icon label-width="130px" label-position="left" class="demo-ruleForm">
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="用户名" prop="userName">
                                <el-input v-model="form.userName" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="密码" prop="passWord">
                                <el-input v-model="form.passWord" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="确认密码" prop="repassWord">
                                <el-input v-model="form.repassWord" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="状态" prop="status">
                                <div class="input_css" style="width: 96%">
                                    &nbsp;
                                    <el-radio-group v-model="form.status">
                                        <el-radio :label=1>启用</el-radio>
                                        <el-radio :label=0>注销</el-radio>
                                    </el-radio-group>
                                </div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="姓名" prop="name">
                                <el-input v-model="form.name" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="职务" prop="jobTitle">
                                <el-input v-model="form.jobTitle" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="性别" prop="sex">
                                <div class="input_css" style="width: 96%">
                                    &nbsp;
                                    <el-radio-group v-model="form.sex">
                                        <el-radio label="男">男</el-radio>
                                        <el-radio label="女">女</el-radio>
                                    </el-radio-group>
                                </div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="电话" prop="phone">
                                <el-input v-model="form.phone" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="手机" prop="cellPhone">
                                <el-input v-model="form.cellPhone" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="短号" prop="cornet">
                                <el-input v-model="form.cornet" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="电子邮件" prop="email">
                                <el-input v-model="form.email" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="邮编" prop="postCode">
                                <el-input v-model="form.postCode" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="地址" prop="address">
                                <el-input v-model="form.address" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="排序" prop="serNumber">
                                <el-input v-model="form.serNumber" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row class="row_Css">
                        <el-col :span="24">
                            <el-form-item label="备注" prop="remark">
                                <el-input v-model="form.remark" placeholder="" style="width: 96%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    



                </el-form>
            </div>
        </div>
        <br />
        <!-- 投资信息 -->
        
        <!-- 按钮 -->
        <div style="text-align: center">
            <el-image :src="submit_img" style="width: 150px; height: 60px" @click="saveOrUpdate"></el-image>
            <!-- <el-image :src="delete_img" style="width: 150px; height: 60px"></el-image> -->
        </div>
    </div>
</el-dialog>
</template>
<script>
export default {
    name:'user_input',
    props:['formVisible', 'formData'],
    data() {
        return {
            type:'',
            submit_img: require('../../../../assets/imgs/组 422.png'),
            delete_img: require('../../../../assets/imgs/组 423.png'),
            labelPosition: 'left',
            form: {}
        };
    },
    created() {
        this.init();
    },
    watch: {
        //监听
        $route(to, from) {
            //路由变化方式，路由发生变化，方法就会执行
            this.init();
        }
    },
    methods: {
        // 保存
        saveOrUpdate() {
            let params = this.form;
            this.form.branchId ='';
            this.form.branchName = '测试部门';
            // params.files=this.fileList
            params.type = this.type;
            this.$post('sysManage/user/save', params).then((res) => {
                if(res.code == 2000){
                    this.$message.success('保存成功!');
                }else{
                    if(res.message){
                        this.$message.error(res.message);
                    }else{
                        this.$message.error('保存时发生错误，请联系管理员');
                    }                    
                }                
            });
        },
        formInit(){
            debugger
            let data=this.formData.pid
            if(data!=undefined){
                this.form=this.formData
                this.stype = '修改模块';
            }else{
                this.pid = this.formData;
                this.stype = '新增模块';
            }

        },
        dialogClose(){
            this.fileList = [];
            this.form = {};
            this.$emit('closeDialog', false);
        },
        init() {
            //判断路径有id值,做修改
            // if ($('#idframe', window.parent.document).attr('data-id') != "undefined") {
            //     //从路径获取id值
            //     var  id = $('#idframe', window.parent.document).attr('data-id');
            //     this.$post('sysManage/user/getInfo/' + id).then((res) => {
            //         console.log(res.data.status)

            //         if(res.code == 2000){
            //             this.form = res.data;
            //             this.form.repassWord = this.form.passWord
            //         }else{
            //             if(res.message){
            //                 this.$message.error(res.message);
            //             }else{
            //                 this.$message.error('保存时发生错误，请联系管理员');
            //             }                    
            //         }                
            //     });

            //     //调用根据id查询的方法
            //     //this.getInfo(id);
            // } else {
            //     //路径没有id值，做添加
            //     //清空表单
            //     //this.ruleForm = {};
            // }
        //     //判断路径有id值,做修改
        //     if (this.$route.query && this.$route.query.type) {
        //         console.log(this.$route)
        //         this.type = this.$route.query.type;
                
        //     } else {
        //         //路径没有id值，做添加
        //         //清空表单
        //     }
         }
    }
};
</script>
<style scoped>
/* 输入框样式 */
/deep/.el-input--small .el-input__inner {
    background: #fff;
    border: 1px solid #2e8ccc;
}
.input_css {
    background: #fff;
    border: 1px solid #2e8ccc;
    border-radius: 4px;
}
/deep/.el-textarea__inner {
    background: #fff;
    border: 1px solid #2e8ccc;
    height: 70px !important;
}
.fontStyle {
    font-size: 20px;
    font-family: '微软雅黑';
    color: #2e8ccc;
    font-weight: 600;
}
.el-divider--horizontal {
    margin: 10px 0;
    background-color: #2e8ccc;
    height: 2px;
}
.row_Css {
    font-size: 18px;
    font-family: '微软雅黑';
    color: #000;
    font-weight: 600;
}
/* /deep/.el-form-item__label{
    text-align: 'left'  !important;
} */
</style>
